home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / sharew / geograph / world_2 / doc / englisch.lst < prev    next >
File List  |  1986-02-05  |  49KB  |  968 lines

  1. read.me                 The World Digitized
  2. vs 1.01                                                         May 1986
  3.  
  4.  
  5.                 The World Digitized is a collection of more than 100,000
  6.         points of latitude and longitude.  When connected together, these
  7.         co-ordinates form outlines of the entire world's coastlands, islands,
  8.         lakes, and national boundaries in surprising detail.
  9.  
  10.                 The philosophy adopted in making The World Digitized
  11.         available to the public is that the exercise of ones own
  12.         creativity and imagination is much more interesting and profitable
  13.         than the acquisition of a fixed program.  The World Digitized is,
  14.         therefore, simply a raw data base sprinkled with a few suggestions
  15.         to be used as jumping off points in your personal quest to create
  16.         significant and dazzling programs.
  17.  
  18.  
  19. Installation:
  20.  
  21.                 The World Digitized is supplied on three 360 KB diskettes.
  22.         Batch files are included to automate the transfer of data to a
  23.         single hard disk under the directory WORLD.  While use of a large
  24.         capacity hard disk is not absolutely necessary, its presence
  25.         certainly makes life a lot easier for work of this volume.  The
  26.         following instructions refer to making that transfer.
  27.  
  28.                 Place Disk 1 of The World Digitized into drive A:.  If
  29.         your hard disk is not drive C:, edit INSTALL.BAT on A: changing
  30.         every occurrence of C: to your target hard drive's designation.
  31.         Then switch to your hard drive [e.g. C:] and change directory
  32.         to the directory in which you want the new directory WORLD to
  33.         be created [e.g. cd xyz  or cd \].  You need about 1.3 MB of
  34.         free space on your hard disk to make the transfer.  Switch back
  35.         to drive A: and execute INSTALL as follows:
  36.  
  37.                         A:
  38.                         INSTALL
  39.  
  40.                 The contents of the three World Digitized diskettes will
  41.         be transfered to your hard disk.  WORLD and a number of sub-
  42.         directories will be created in the process.
  43.  
  44.  
  45. What You Got:
  46.  
  47.                 The World Digitized is segregated into directories and
  48.         into files within the directories for ease of use.  First are
  49.         some files of general or early interest kept directly under
  50.         the WORLD directory:
  51.  
  52.                 read.me      -  this file.
  53.                 copying      -  details of your right to copy (save)
  54.                 install.bat  -  installation batch file.
  55.                 install1.bat -  2nd part of install.
  56.                 expand.bat   -  data base converter control file.
  57.                 mpstomp1.exe -  shipping to ASCII file converter.
  58.                 mpstomp1.c   -  source of converter.
  59.  
  60.                 demo         -  Source files of the Alaska demo.  The
  61.                                 corresponding demo.mp2 file is not included
  62.                                 because of lack of space.  You can make
  63.                                 your own from a subset of NA*.mp1
  64.  
  65.                 Africa
  66.  
  67.                         AF0     -  coastlands
  68.                         AF1     -  islands
  69.                         AF2     -  lakes
  70.                         AF3     -  political boundaries (includes Middle East)
  71.  
  72.                 Antarctica
  73.  
  74.                         AN0     -  coastlands
  75.                         AN1     -  islands
  76.  
  77.                 Asia
  78.  
  79.                         AS0     -  coastlands
  80.                         AS1     -  islands
  81.                         AS2     -  lakes
  82.                         AS3     -  political boundaries
  83.  
  84.                 Australia
  85.  
  86.                         AU0     -  coastlands
  87.                         AU1     -  islands
  88.                         Au2     -  lakes
  89.  
  90.                 Europe
  91.  
  92.                         E0      -  coastlands
  93.                         E1      -  islands
  94.                         E2      -  lakes
  95.                         E3      -  political boundaries
  96.  
  97.                 Northamerica
  98.  
  99.                                    primarily Canada and Alaska
  100.                         NA0     -  coastlands
  101.                         NA1     -  islands
  102.                         NA2     -  lakes
  103.                         NA3     -  political boundaries
  104.  
  105.                         USA0    -  coastlands
  106.                         USA1    -  islands
  107.  
  108.                                    Greenland
  109.                         GR0     -  coastlands
  110.                         GR1     -  islands
  111.  
  112.                         PA1     -  Hawaii and mid Pacific islands
  113.  
  114.                 Southamerica    with Central America and Caribbean
  115.  
  116.                         SA0     -  coastlands
  117.                         SA1     -  islands
  118.                         SA2     -  lakes
  119.                         SA3     -  political boundaries
  120.  
  121.  
  122. Expanding Files:
  123.  
  124.                 For the purposes of shipping, the normal ASCII files which
  125.         hold The World Digitized (.mp1 format) have been compressed into
  126.         binary (.mps) formated files.  You can expand the binary files
  127.         into their ASCII conterparts by executing the program
  128.  
  129.                         mpstomp1 file_name b:
  130.  
  131.                 where:
  132.  
  133.                         file_name is the name of a .mps file without
  134.                                   extension or drive designation.
  135.  
  136.                         b: is the designation of the destination drive.
  137.                            It may be your current drive.
  138.  
  139.         The result will be the newly created file b:file_name.mp1.  You
  140.         can use your favorite text editor to view or modify any .mp1 file.
  141.  
  142.                 The batch file EXPAND.BAT is provided to expand all your
  143.         .mps files automtically.  Be sure that you have approximately
  144.         1.8 MB free space on your disk before executing this file.  Again
  145.         the assumed designation of your hard drive is C:.  If this is not
  146.         so, edit EXPAND.BAT to correct the destination drive on each
  147.         line where C: is used.  EXPAND.BAT takes about one and a quarter
  148.         hours to run.
  149.  
  150.  
  151. Concatinating Files:
  152.  
  153.                 Expanded .mp1 text files and .mp2 binary files can
  154.         be concatinated into large .mp1 and .mp2 files if you want
  155.         to use more than one small section of The World Digitized
  156.         at a time.  You might, for instance, desire to display the
  157.         coastlands, islands, lakes, and political boundries of Asia
  158.         together.  Asia was shipped as four separate files.  They can
  159.         be concatinated with the PC DOS copy command:
  160.  
  161.                 copy as*.mp1 large.mp1
  162.  
  163.         or
  164.  
  165.                 copy/B as0.mp2+as1.mp2+as3.mp2+as4.mp2 asia.mp2
  166.  
  167.         Note the use of the /B binary switch when concatinating binary
  168.         files.  This switch is necessary because binary data might
  169.         be interpreted as the End-of-File marker (Ctrl Z) expected
  170.         at the end of default ASCII files.
  171.  
  172.  
  173. Making Backups:
  174.  
  175.                 You are encouraged to make backup copies of any and all
  176.         the material you received with The World Digitized.  You are
  177.         even encouraged to make copies for your friends as long as you
  178.         include the COPYING file and inform them of their obligation to
  179.         obtain a product license.  They can be both licensed and put on
  180.         a list for possible future product announcements by sending $20 to:
  181.  
  182.                         The World Digitized
  183.                         Dept. PC SIG
  184.                         166 Shady Lane
  185.                         Apollo, PA 15613
  186.  
  187.         User Supported Software benefits everybody concerned.
  188.  
  189.                 Your license extends to your personal use of The World
  190.         Digitized.  Both it and its derivatives are Copyright 1986 by
  191.         John B. Allison.
  192.  
  193.  
  194. Special Educational License:
  195.  
  196.                 If you are involved with teaching, a special Educational
  197.         License can be obtained by sending $65 to the above address.
  198.         This will license you to use The World Digitized not only in your
  199.         private activity, but also extends those rights to those whom you
  200.         teach while they are in your classroom or lab setting.  Students
  201.         wishing to use these materials or their derivatives at home should
  202.         register personally as outlined above.
  203.  
  204.  
  205. Related Products:
  206.  
  207.                 A completed version of Programs I - V outlined below is
  208.         available from The World Digitized.  Send $19 (plus 6% sales tax
  209.         for those with Pennsylvania mailing addresses) and ask for the
  210.         Simple Display Program.  Source versions for the Simple Display
  211.         and mp1tomp2 programs will be supplied on a single diskette.
  212.         The Educational License for use of these programs is $59.
  213.  
  214.  
  215. Accuracy vs. Precision:
  216.  
  217.                 You may be lulled into thinking that the coastal outlines
  218.         included in this product are highly accurate.  I wish they were!
  219.         Implicit in the Real variables used to record The World Digitized
  220.         data are seven or eight digits of accuracy.  Go to Double Precision
  221.         (which is the C language default), and you have 17 places!  The
  222.         latitudes and longitudes in .mp1 files are limited to 3 places
  223.         to the right of the decimal, primarily to save disk space.  One
  224.         thousandth of a degree of a Great Circle of the Earth is 0.069 miles.
  225.         (3959 mi radius * 2pi/360 deg = 69 miles/deg) The unwary might
  226.         incorrectly conclude that this precision implies co-ordinate accuracy
  227.         to within 365 feet!
  228.  
  229.                 You will observe goofs in The World Digitized many times
  230.         this amount.  In fact extraneous points were disposed of which
  231.         were separated by less than a mile.  Yet although this data base
  232.         may lack absolute accuracy when viewed from a global perspective,
  233.         relative to their neighbors, most of the points are suprisingly
  234.         accurate.
  235.  
  236.  
  237.  
  238.  
  239. Data Formats:
  240.  
  241.                 Three formats are used to store The World Digitized
  242.         data base.
  243.  
  244.                 .mps    -  binary for shipping and space saving
  245.  
  246.                 .mp1    -  ASCII, latitude and longitude with comments
  247.  
  248.                 .mp2    -  binary, Mercator y and longitude for speed
  249.                            and proper vertical scaling.
  250.  
  251.         In general, all these file formats are characterized by
  252.         strings of data records representing connected points.  String
  253.         terminations are marked by separator records or fields which
  254.         delineate the strings from each other.
  255.  
  256.         .MP1 File Format:  variable length ASCII records
  257.  
  258.             Data Records
  259.                 field
  260.                   1     latitude        floating point number
  261.  
  262.                   2     blank           field separator
  263.  
  264.                   3     longitude       floating point number
  265.  
  266.                  [4]    optional        begining with a blank
  267.                            comment
  268.  
  269.                   5     line feed       end of record (LF - 10)
  270.  
  271.            Separator Records
  272.                 field
  273.                  [1]    optional blanks[s]
  274.  
  275.                   2     line feed       end of record (LF - 10)
  276.  
  277.  
  278.         .MPS File Format:  variable length mixed binary/ASCII records
  279.  
  280.                 field
  281.                   1     latitude        4 byte binary floating
  282.  
  283.                   2     longitude       4 byte binary floating
  284.  
  285.                  [3]    optional        ASCII characters
  286.                            comment
  287.  
  288.                  [4]    optional        end of string (SOH - 1)
  289.                            separator
  290.  
  291.                   5     line feed       end of record (LF - 10)
  292.  
  293.  
  294.         .MP2 File Format:  fixed length (10 byte) binary records
  295.  
  296.                 field
  297.                   1     type            2 byte integer
  298.                                                 0  -  start of a new string
  299.                                                 1  -  continuation of a string
  300.  
  301.                   2     latitude        4 byte binary floating
  302.  
  303.                   3     longitude       4 byte binary floating
  304.  
  305.  
  306.                         Programming Suggestions Using
  307.  
  308.                         The World Digitized Database
  309.  
  310.  
  311.                               John B. Allison
  312.  
  313.  
  314.  
  315.  
  316. I.  Simple display program:
  317.  
  318.    1.   Define a world co-ordinate system whose lower left corner
  319.         is -246 (degrees West Long), -85 (degrees South Lat) and
  320.         whose upper right corner is 246, 85.
  321.  
  322.    2.   Draw lines of latitude and longitude every 20 degrees
  323.         labeling them.
  324.  
  325.    3.   Traverse a .mp1 formatted file plotting lines from latitude/
  326.         longitude point to point.  Terminate the current sequence
  327.         of connected lines at a blank input record and prepare to
  328.         start a new sequence if there is one.
  329.  
  330.    4.   The name of the file to be displayed must be accepted
  331.         as a command line argument.
  332.  
  333.    5.   The program should exit after it displays for about 30 seconds.
  334.  
  335. II.  Simple zoom display program:
  336.         Provide the ability to zoom in on a chosen area of the display
  337.         in the previous program.
  338.  
  339.    1.   Convert the mainline function of your Simple Display Program (I)
  340.         to a function named "display1()".
  341.  
  342.    2.   Write the function "zoomwin()" which resets the world co-ordinates
  343.         of the display based on input returned by "getlocs(x, y)" called
  344.         from within "zoomwin".
  345.  
  346.         The aspect ratio of the world co-ordinates must be maintained
  347.         even though the requested zoom is not in correct proportion.
  348.  
  349.         One way to signal program termination is for "zoomwin" to return
  350.         TRUE if a the zoom was accomplished and FALSE if the same corner is
  351.         entered twice.  The mainline alternately calls "display1" and
  352.         "zoomwin".
  353.  
  354.    3.   "Getlocs(x, y)" returns the display co-ordinates of window
  355.         corners entered to mark the desired extent of the new display.
  356.  
  357.         Dynamically mark the current cursor position (which is initially
  358.         centered) by cross hairs.  Move the cross hairs by the keypad
  359.         arrow keys (1, 3, 7, and 9 can be used for diagonal movement).
  360.  
  361.         Cursor jump should be the minimum detectable on your display
  362.         unless the shift key is simultaneously held down.  Then it
  363.         should be 10 times the minimum.
  364.  
  365.         Striking the Return key should "mark" a corner of the zoom
  366.         window with permanent dashed cross hairs.  The user will then move
  367.         the solid cross hairs to mark the second diametrically opposed
  368.         corner with a second Return.
  369.  
  370.         The decimal values returned by striking the keypad keys follow:
  371.  
  372.                 key     byte1   byte2
  373.  
  374.                 1       0       79
  375.                 2       0       80
  376.                 3       0       81
  377.                 4       0       75
  378.                 5       0       76
  379.                 6       0       77
  380.                 7       0       71
  381.                 8       0       72
  382.                 9       0       73
  383.  
  384. III.  Display Program with Mercator Projection:
  385.         You may have noticed distortion in the maps displayed in the
  386.         previous programs, epecially at extreme latitudes.  This
  387.         distortion is caused by an attempt to map the curved surface
  388.         of a three dimensional globe onto a two dimensional plane.  As
  389.         you travel toward the poles, the 360 degrees of longitude are
  390.         squeezed into less and less space on the globe, but not on the
  391.         plane.
  392.  
  393.         There are many ways to compensate for the distortion problem.
  394.         Probably the solution most widely recognized is the Mercator
  395.         projection, named for a famous early map maker.  Mercator's
  396.         projection has the characteristics that both lines of latitude
  397.         and longitude are straight and at right angles to each other
  398.         (orthogonal).  In addition, if a small area is viewed, there
  399.         is no distortion of form: areas have the right shape although
  400.         the vertical scale and total area is distorted as you move from
  401.         the equator.
  402.  
  403.         The formula for the Mercator projection is
  404.  
  405.                 y = ln{tan[45 deg + latitude/2)/deg_per_radian]}
  406.  
  407.         Check out the Encyclopedia Britannica under Map for all this
  408.         good stuff and more.
  409.  
  410.    1.   Use the Mercator formula in a function which, when passed a
  411.         latitude in degrees, returns a vertical displacement.  Can you
  412.         predict what sorts of evil things happen at the poles (90 and -90)?
  413.  
  414.    2.   Use the function "mercator(lat)" to give the correct vertical
  415.         displacement when generating graphics in Program II.  Set the
  416.         corners of the world co-ordinates to (-246,-2.9) and (246, 2.9).
  417.         The horizontal scale is still in degrees while the vertical
  418.         is in Mercator displacement units.
  419.  
  420. IV.  Faster Display Program:
  421.         What you gained in making your display look more realistic
  422.         you paid for in speed.  Real division and tangent and log
  423.         functions take time, even with a math chip.  The extra time
  424.         can be more than made up for by reading the pre-calculated
  425.         Mercator displacement and longitude from a binary file rather
  426.         than latitude and longitude from a text file.
  427.  
  428.    1.   Alter the input function of your display program to open and
  429.         read from a binary .mp2 formatted file rather than from an
  430.         ASCII .mp1 formatted file.  (Refer to the section on File
  431.         Formats for a detailed description.)
  432.  
  433.    2.   Write a program called mp1tomp2 which converts .mp1 files to
  434.         .mp2 files.  This program should accept the name of the file
  435.         (without extension) as the first command line argument and the
  436.         destination disk as the second argument.
  437.  
  438.  
  439. V.  Display Program with Print:
  440.         A nice addition to your display program is the ability to
  441.         reproduce the displayed image on the printer.  This is an
  442.         easy addition in some graphics languages.
  443.  
  444.    1.   Add a call to print the displayed image.  The call should be
  445.         added to function "getloc()" and activated by entering "p"
  446.         from the keyboard.  Note that upper case "P" (preceded by a
  447.         null) will result from striking keypad "2".
  448.  
  449.  
  450. Note:  If you are having trouble with the Simple Display Program outlined
  451.         above, don't be discouraged.  The program is not really simple!
  452.         When you put enough simple things together, they inevitably become
  453.         complicated by the nature of their mututal interactions.  That's what
  454.         structured programming is all about: designing simple and logical
  455.         interfaces between the many pieces.  The first rule of programmning
  456.         is never to attempt any truly difficult programs because even simple
  457.         programs are difficult.
  458.  
  459.         If you have simply come up against a dead end or if an alternate
  460.         solution is desired, the completed source of Programs I - V is
  461.         available from The World Digitized.  Send $19 and ask for the
  462.         Simple Display Program.  C language source for the simple display
  463.         and mp1tomp2 will be supplied on a single diskette.
  464.  
  465. VI.  Simple Display Program with Scale of Miles:
  466.         As you zoom the display up further and further, you know that
  467.         you are getting up closer, but its easy to loose track of the
  468.         scale, the number of miles from one point to another, or the distance
  469.         across the screen especially with the inherent scale distortion in
  470.         latitudes greater than 30 degrees.
  471.  
  472.    1.   Add a function which prints an indiction of the scale along the
  473.         bottom of the display.  This indication can be a solid horizontal
  474.         line labeled with its length: 1000 miles, 100 miles, 10 miles, 1 mile,
  475.         or whatever is appropriate.  Alternately the indication could be
  476.         text showing the width of the screen.  In either case the scale
  477.         represented should be that scale at the middle of the screen.
  478.         You will need to define the inverse Mercator function "mercainv(y)"
  479.         to return the latitude when supplied with the vertical offset
  480.         from the equator.
  481.  
  482.    2.   Another interesting indicator is the zoom factor which can be
  483.         placed at either the top or bottom of the display.  Define the
  484.         initial display zoom ratio as 1.0.  As you zoom in, that ratio
  485.         increases.  Professional CAD (Computer Aided Design & Drafting)
  486.         systems once blew up at factors of about 500.  You will be surprised
  487.         at how far your display can zoom.  The limit is ultimately dependent
  488.         upon the data representation, single precision real in  the case of
  489.         Halo.
  490.  
  491.  
  492. VII.  Simple Display Program with Location Display:
  493.         You will want to be able to display the geographic location of any
  494.         point on your display.  The inverse Mercator function "mercainv()"
  495.         you constructed for the previous program will be useful.
  496.  
  497.    1.   Add the function "markloc()" which, when called by entering the
  498.         letter "M", displays the cross hairs on the screen.  The cross hairs
  499.         can be moved with the keypad as in windowing for a zoom, but when a
  500.         single Return is entered, a small cross is left to mark the
  501.         spot.  To the right of the cross (or to the left as spacing permits),
  502.         print the latitude and longitude of the location.  This feature is
  503.         invaluable when trying to relate points on your graphics display
  504.         to the source .mp1 files.
  505.  
  506.  
  507. VIII.  Simple Display Program with Unzoom:
  508.         Now that you can zoom your display anywhere at will, it would
  509.         be convenient to be able to change your mind, backup to a
  510.         previous display, and commence again.  The ability to change
  511.         your mind is available in commerical packages such as Computer-
  512.         vision's CADDS 4X graphics system.  In their system a command is
  513.         never "final" until you hit the Return key.  The results of your
  514.         actions are shown graphically as you enter them, however.  If you
  515.         don't like what you just did, you always have the option of aborting
  516.         the command while it is still in progress and returning, graphics
  517.         display as well as data base, back to the pre-command state. Pretty
  518.         nifty!
  519.  
  520.                 Without getting into CV's total command interpretor
  521.         solution which is complicated and arguably ghastly to program,
  522.         there is an interesting solution with two variations for the
  523.         lesser problem of returning to previous states from the current
  524.         one.  First of all the states which must be saved are the zoom
  525.         extents  -  the world co-ordinates for each sucessive zoomed
  526.         display.  The most straight forward implementation is to store
  527.         each sucessive display in an array (or a C structure).  Each time
  528.         the display is zoomed, the old drawing extents (corners) are
  529.         stored as the next elements of the array.  To get back to any
  530.         previous zoom ratio, the old extents are retrieved from the
  531.         array, the last-valid-element-marker of the array is moved
  532.         backward, and the drawing is redisplayed.  Care must be taken
  533.         not to overflow the array.
  534.  
  535.                 The more interesting but functionally equivalent approach
  536.         is to recursively have "zoomwin()" call itself thereby storing
  537.         past extents (and all other variables) on the stack.  "Zoomwin()"
  538.         must also call "display2()" directly so the drawing can be re-
  539.         displayed after each zoom.  Recursion has the advantage of
  540.         automatically handling the record keeping chores  -  no extra
  541.         arrays are necessary.  Recursion is also intellectually challenging.
  542.         People don't think that way naturally and its fun to try.  Recursion
  543.         should only be used where it is truly advantageous.  Don't use it
  544.         where a simple loop will do.  Be sure that you prepare a way of
  545.         returning back to yourself otherwise you will recurse yourself
  546.         right off the end of the stack.
  547.  
  548.                 If your stack is too small, the program will fail at
  549.         run time with a *** STACK OVERFLOW *** message if you're lucky.
  550.         Executing your program
  551.  
  552.                         PROGRAM =8000
  553.  
  554.         will allocate an 8000 bytes stack to you program instead of its
  555.         default (2048?).  The linker has an optional stack switch good
  556.         up to 64k, and the Lattice C compiler supports a larger default
  557.         declaration programmatically.
  558.  
  559.    1.   Add the capability to your program to unzoom.  This can be done
  560.         by assigning the Esc key the meaning to backup one level and
  561.         redisplay.  For backing up several levels at once (redisplay
  562.         takes time), the sequence "-n" where "n" is a single digit
  563.         should be used.
  564.  
  565.  
  566. IX.  Simple Display Program which Includes a City/Nation Database:
  567.         The World Digitized comes with no cities.  Making a list of
  568.         the major (perhaps captial) cities of the world with their
  569.         co-ordinates is a straight forward task.
  570.  
  571.    1.   Make a list of major cities/countries and organize them into file
  572.         structure suitable for both sequencial and random processing.  Modify
  573.         the simple display program so that cities are displayed when
  574.         a "c" is entered.  The cities are displayed by a small filled
  575.         circle or square.  Choose different shapes or sizes depending
  576.         on population.  Print the name of the city beside its shape.
  577.  
  578.    2.   Modify the simple display program to display (at the current
  579.         zoom factor) a city and its surroundings when an "f" (for find)
  580.         and its name is entered.  Develop a method for handling ambiguous
  581.         cases by listing the possible cases and asking for additional
  582.         information such as state or nation.
  583.  
  584.    3.   Modify the simple display program to display the names of the
  585.         nations when an "n" is entered.  If you enter "f" for find and
  586.         the name of a nation, it should be displayed as in 2 above.
  587.  
  588.  
  589. X.  Program to Display in Polar Co-ordinates:
  590.         If you aren't entirely sick of map display programs by now,
  591.         design one to display in polar co-ordinates.  The most suitable
  592.         continent to display, of course, is Antarctica.  Remember it
  593.         is in the southern hemisphere, and therefore mathematically
  594.         backward or inside out.
  595.  
  596.  
  597. XI.  Program to Automatically Clean Up Database:
  598.         As you have already discovered by this time, there are many
  599.         small errors in The World Digitized database.  The number
  600.         of points and the difficulty of interpreting them outside
  601.         of a graphics context makes correcting these errors by
  602.         hand tedious and error prone.  Any programs which can
  603.         be developed to locate and correct errors automatically
  604.         are valuable and inately fulfulling.  Here's your chance
  605.         to be fulfilled.
  606.  
  607.    1.   Closure on many closed bodies such as islands and lakes is
  608.         not complete.  The database consists of strings of co-ordinates
  609.         separated by blank lines.  The first point of the next string
  610.         may be either a continuation of the same body or the start
  611.         of a new one.  Write a program which traverses .mp1 files
  612.         outputing each record to an output file.  When a new
  613.         string is found, determine whether the new string is a
  614.         continuation of the old one (is sufficiently close to the
  615.         last point of the old string) or is the start of a new body.
  616.         If it is a continuation of the same body, the blank record
  617.         should be left out.  If it is the start of a new body, an
  618.         additional or a replacement last record should be inserted
  619.         in the output file which matches the first point of the old
  620.         body thus assuring closure.  There is a strong possibility
  621.         that the relation of the strings and points is indeterminate
  622.         automatically.
  623.  
  624.    2.   Two more problems affecting the reasonableness of the data in
  625.         the database are lines which cross themselves and angles
  626.         which are unnaturally acute.  Perhaps both these problems can
  627.         be addressed by solving the acute angle problem.  Write a
  628.         program which, as in case 1 above, reads a .mp1 file and outputs
  629.         good records to another .mp1 file.  Discard any point n which
  630.         causes vectors drawn from n-2 to n-1 and from n-1 to n to
  631.         form an angle of less than 45 degrees.
  632.  
  633.         While this approach probably will solve many problems automatically,
  634.         it is not a fool-proof solution.  First of all the results, the
  635.         points discarded, are dependent on the order of traversing the
  636.         database.  Is there any way of avoiding this problem?  Secondly
  637.         and perhaps more obvious to you, throwing out point n associated
  638.         with an acute angle may leave us with an equally bad n+1 point
  639.         and angle.  In the case of very small islands, the whole island
  640.         may disappear, which may not be all bad.  But you could conceive
  641.         of whole spits or heads of islands being radically changed.
  642.  
  643.         Perhaps the best solution to problems of the types outlined in
  644.         cases 1 and 2 is to try to combine automatic scanning with
  645.         graphical display and human decision making at difficult points.
  646.  
  647.  
  648. XII.  Mathematical Analysis of the Data:
  649.         Several interesting programs can be written which investigate
  650.         the relationship of the World Digitized co-ordinates to each
  651.         other from a purely mathematical perspective.
  652.  
  653.    1.   Write the function "spheremi(lat0, long0, lat1, long1)" which
  654.         returns the distance in statute miles separating two close places
  655.         on the earth.  For the sake of simplicity and speed of execution,
  656.         you should assume that the chord approximates the arc of a swept
  657.         angle for small angles or sin(theta) = tan(theta) = theta (in radians)
  658.         for small theta's.  The circle we are talking about, of course,
  659.         is the great circle of the earth.  The earth's radius is 3959 miles.
  660.         Remember that while distance is linearly related to degrees of
  661.         latitude, distance is not linearly related to degrees of longitude
  662.         but depends on the latitude.
  663.  
  664.    2.   Using the function "spheremi()", write a program to calculate
  665.         the total length of the coastlines of the world.
  666.  
  667.    3.   Write a program which prints a histogram or a curve of the
  668.         distribution of the lengths of the vectors making up the
  669.         coastlands of the world.  One would expect the distribution to
  670.         be "normal", or perhaps the log of the distribution because the
  671.         lower bound is 0 while the upper is infinite.  Can you explain
  672.         why it is not normal?  Is the average vector length different for
  673.         high latitude sections of the database versus equitorial regions?
  674.  
  675.    4.   Write a program to calculate the area of enclosed figures (islands).
  676.         I'm not acquainted with the mathematical theory needed to solve this
  677.         problem, but I bet its simple and powerful.  The storage require-
  678.         ments of the program will probably also increase at least linearly
  679.         with the number of vectors making up the figure to be evaluated
  680.         making exact calculations of larger areas (continents) difficult.
  681.         Use related algorithms to calculate the center of mass, moments
  682.         of inertia, etc.
  683.  
  684.  
  685. XIII.  Program to Insert a B-spline:
  686.         As you zoom in closer and closer in your display of The World
  687.         Digitized, the disjointed nature of the data begins to look very
  688.         unnatural.  Running a B-spline between points would insure that
  689.         the slope of the curve at all points is continuous adding to
  690.         the realism.
  691.  
  692.    1.   Write a variation of the Simple Display Program which would
  693.         calculate and display a cyclic cubic spline for a limited
  694.         number of points in the display area when zoomed up enough
  695.         to make the discontinuous nature of the data obvious.
  696.  
  697.    2.   Devise a method to store the parameters of the spline in a
  698.         binary file ahead of time to reduce the run time calculations.
  699.  
  700.         The mathematics of b-splines are beyond the scope of these
  701.         programming suggestions to cover.  Rogers and Adams in the
  702.         Mathematical Elements for Computer Graphics, McGraw-Hill, 1976
  703.         discuss cyclic cubic splines.  See page 129 for pictures.
  704.  
  705.  
  706. XIV.  Program to Add More Resolution:
  707.         There is only so much information that is carried in a given
  708.         drawing or database.  The measure of that information is the
  709.         number of points defining the vectors.  You might suppose that
  710.         it is impossible to add information which is not already explicitly
  711.         there.  Using the b-spline techniques suggested in the last
  712.         program, it is possible to generate more data based on the
  713.         implied relationship of the points to each other.
  714.  
  715.    1.   Build a program which reads in a series of points, constructs
  716.         a spline along those points, and finally approximates the
  717.         spline with a new set of points at twenty times the density
  718.         of the original defining points.
  719.  
  720.  
  721. XV.  Program to Reduce Resolution:
  722.         There are cases in which the detail of the database might be
  723.         too much for the application.  This overkill would not only
  724.         slow the display repaint down unnecessarily, but would consume
  725.         extra disk space.
  726.  
  727.    1.   Develop an algorithm to cull unneeded points from a database
  728.         (.mp1 format) outputing the new shorter file.  The trick is
  729.         to dispose of "extra" points without deforming the coastland
  730.         being reduced.  The simplest approach would be to skip 9 points
  731.         out of every 10 if you wanted an output with one tenth the
  732.         resolution.  That might work tolerably if you were sure of
  733.         a uniform distribution of points to begin with.  A better
  734.         solution is to use the "spheremi()" function developed previously
  735.         to skip those points closer together than the resolution you
  736.         require.  The algorithm is to accept the first point and to
  737.         look for the next point that falls outside the radius of
  738.         minimum resolution from the first point.  Write out this
  739.         accepted point.  It now becomes your new first point.
  740.  
  741.    2.   There may be cases in which the points are separated by
  742.         distances greater than the minimum resolution but which fall
  743.         almost in a straight line.  Define a minimum channel width.
  744.         Points falling within this channel can be replaced by a
  745.         single straight line from the first point in the channel to
  746.         the last point in the channel.  This algorithm is a little
  747.         more challenging and a little more compute intensive.  It
  748.         assumes that the points have passed the minimum radius test
  749.         outlined above.  Starting with the second point beyond the
  750.         anchor point, imagine a line back to the anchor point.  If
  751.         the first point beyond the anchor point is within the channel
  752.         width's distance to that line, it may be discarded.  Advance
  753.         to point 3 and check points 2 AND point 1 again.  The process
  754.         stops when a point n is chosen such that one of the points 1
  755.         through n-1 falls outside the channel.  Point n-1 is retained.
  756.  
  757.         You can see the need for checking back through all the points
  758.         to the anchor each time if you consider what would happen if
  759.         you tried to reduce a coastland whose points all gently arced
  760.         around in a complete circle.  Adjacent points would always
  761.         be within the channel while the overall shape is obviously not
  762.         a straight line!  You can also appreciate the non-linear
  763.         aspect of the number of calculations required as you walk
  764.         back further and further to discard more and more points.
  765.  
  766.         I am not convinced that these two approaches to database pruning
  767.         outlined above will always yield satisfactory results.  Grotesque
  768.         spurs not representative of the original coastal outline might
  769.         in some cases be generated (or rather left).  Play with this
  770.         problem and see if you can come up with a better solution.
  771.  
  772.  
  773. XVI.  A Program to Generate Pseudo Detail:
  774.         The June 1982 issue of the Communications of the ACM contains
  775.         the article "Computer Rendering of Stochastic Models" authored
  776.         by three individuals, one from Lucasfilm.  The abstract reads
  777.         in part "A recurrent problem in generating realistic pictures
  778.         by computers is to represent natural irregular objects and
  779.         phenomena without undue time or space overhead.... A major
  780.         advantage of this technique is that it allows us to compute
  781.         the surface to arbitrary levels of details without increasing
  782.         the database.  Thus objects with complex appearances can be
  783.         displayed from a very small database."  The authors go on to
  784.         give example code in Pascal (page 376) and generate a map of
  785.         Australia from only eight points!
  786.  
  787.    1.   Obtain the article and implement a two dimensional version for
  788.         use based on data from The World Digitized.
  789.  
  790.  
  791. XVII.  A Program to Edit Graphics:
  792.         Programmers have written more text editors than you can shake a
  793.         stick at.  A GOOD graphics editor for .mp1 files would be unique
  794.         and useful (The World Digitized containing assorted, and we might
  795.         add, minor errors).  Without a graphics editor, the process
  796.         of relating mistakes from the graphics display program back to
  797.         the .mp1 source file is difficult and error prone.  In addition
  798.         the changed .mp1 file must be translated into its .mp2 version
  799.         before redisplay and confirmation.
  800.  
  801.    1.   Write a graphics editor for .mp1 files.  To keep the response
  802.         snappy, it should not display the whole or large sections of
  803.         a database file unless asked to do so.  One should be able to
  804.         ask for a latitude and longitude at which point the graphics editor
  805.         scans the .mp1 text file looking points in that location's vicinity.
  806.         N points (10 to 100, a setable value) should be displayed.  The
  807.         program must calculate the proper world co-ordinates based on the
  808.         points chosen for this display.  The exact point requested should
  809.         be marked.  Points themselves should be marked with small circles
  810.         and linked with straight lines.  The editor should allow points
  811.         to be deleted, moved, or added using keypad control for selection
  812.         and positioning.  Multiple scans forward and backward through
  813.         the database should be allowed.
  814.  
  815.         The problems of writing good programs fall into two parts: writing
  816.         a good design specification and choosing the appropriate algorithm
  817.         for implementation.  This project is challenging on both counts.
  818.         Writing a design spec must be a little like writing a murder mystery.
  819.         You sit down, close your eyes, and ask what your user really wants
  820.         to do.  You dream up the smallest number of commands which will
  821.         enable him to do this function well.  You mull them over in your
  822.         mind.  The commands are your mystery characters.  You want to develop
  823.         their personalities fully.  Are the commands coherent?  Can they be
  824.         simpler in syntax yet more powerful, ie. open-ended, all encompassing,
  825.         or open to ways of use not forseen by you, the author.  Of course there
  826.         is a limit to what conjecture can accomplish.  You must write the
  827.         syntax of your user interface (language) down and program it.  If
  828.         the application is obvious or if you're experienced, your first pass
  829.         attempt may be the final version.  More often, however, we learn
  830.         from exercising this prototype.  That's why there are so many version
  831.         2.0 programs floating around!
  832.  
  833.         The graphics editor program may have (depending on your final design)
  834.         commands such as:
  835.  
  836.                         FIND latitude longitude
  837.                         SEARCH FORWARD
  838.                         SEARCH BACKWARD
  839.                         SEARCH ALL
  840.                         SEARCH ONE
  841.                         SET DISPLAY n
  842.                         DELETE
  843.                         MOVE
  844.                         ADD
  845.                         UNDO LAST
  846.                         UNDO ALL DISPLAYED
  847.                         DISPLAY ORIGINAL
  848.                         DISPLAY NOORIGINAL
  849.                         MEASURE DISTANCE
  850.                         MEASURE LENGTH
  851.                         EXIT
  852.                         QUIT
  853.  
  854.         You have the choice of implementing your grammar in a type-it-in
  855.         interface if you're from the I-like-to-type school or as a series
  856.         of menus if you're from the button-pushing school.  Unless you're
  857.         very experienced, either interface is a small project in and of
  858.         itself in the graphics display context where you usually must
  859.         solicit and display each character yourself while handling the
  860.         delete, backspace, and newline functions normally taken care of by
  861.         the terminal driver.
  862.  
  863.         Just as important as what the graphics editor is going to do is
  864.         how it is going to do it.  Issues of simplicity and performance
  865.         loom before us.  Text editors usually manipulate an in-memory linked
  866.         list of lines.  Large files complicate the issue by forcing portions
  867.         of this linked list to be written to disk as internal buffers are
  868.         filled.  Functions such as the unlimited backward scan of text may
  869.         be inhibited or become programmatically complex.
  870.  
  871.         This graphics editor is different from a text editor in that while
  872.         it most assuredly does handle large text files, most of the changes
  873.         to be made are minor in comparison to the bulk of data which is
  874.         already in place.  Therefore a simpler strategy for recording
  875.         changes, additions, and deletions is in order.  One method is for
  876.         the editor to keep track of the line numbers of the displayed points.
  877.         When changes, additions, or deletions are made, records of these
  878.         transactions along with the related source code line numbers are
  879.         stored in an in-memory structure.  The structure may have either
  880.         linked records, be indexed in some fashion, or be sequentially
  881.         scanned for access.  The details and trade offs of the strategy
  882.         are best left to the implementor.  In any event, after a change
  883.         has been made to a section of the display and that section is left
  884.         and returned to or searched for later, the new version must be
  885.         displayed rather than the original version (except upon request).
  886.         A new .mp1 file must be created at editor exit time by copying the
  887.         original to the new with the appropriate changes folded in.  The
  888.         original .mp1 file should be renamed with a .bak extension.
  889.  
  890.  
  891. XVIII.  A Program to View the World Digitized as a Globe:
  892.         Until this point we have been using The World Digitized in two
  893.         dimensional applications.  Although perphaps not obvious, The World
  894.         Digitized is inherently a 3 dimensional database.  The co-ordinates
  895.         of latitude and longitude are mappings from a sphere, a three
  896.         dimensional solid.
  897.  
  898.    1.   Create a function which will translate co-ordinates given in
  899.         latitude/longitude to Cartesian co-ordinates.  The input arguments
  900.         are latitude, longitude, and altitude above the surface of the
  901.         earth, and the output arguments x, y, and z.  Define the x-y
  902.         plane to lie in the plane defined by the great circle of the
  903.         equator with the positive x axis running from the center of the earth
  904.         (the origin) through the Prime Meridian (longitude = 0).  In keeping
  905.         with right handed conventions, the positive z axis runs from the
  906.         earth's center through the Georgraphic North Pole.
  907.  
  908.    2.   Use the function created in step 1 to display .mp2 files in
  909.         3 space.  The details of the three-dimensional matrix transforms
  910.         and projections are beyond the scope of this tutorial.  Rogers'
  911.         and Adams' book mentioned above treat these subjects thoroughly.
  912.         A few general observations are in order, however.  You will have
  913.         to choose a view point for your perspective, beyond the surface
  914.         of the earth to begin with.  The view point for your projection
  915.         can be at infinity or at some finite distance.  You may want to
  916.         choose your initial view point along the x axis (y = z = 0).
  917.  
  918.         Objects on the far side of the earth will be visible unless you
  919.         clip them.  One solution is to clip everything beyond a plane
  920.         passing through the center of the earth and lying parallel to the
  921.         plane of the display.  This is known as z-clipping although if
  922.         your view point lies on the positive x axis it would be literally
  923.         -x axis clipping.
  924.  
  925.         Objects which lie toward the limb of the earth will be viewed
  926.         almost edge on.  You may have noticed that the horizon from
  927.         satellite pictures is indistinct.  That phenomenon may be due,
  928.         in part, to the additional haze of the earth atmosphere, but at
  929.         best those objects would be hard to distinguish because of
  930.         perspective.  You may wish to clip objects not only on the far
  931.         side of the earth, but those just on this side of the horizon.
  932.  
  933.  
  934.  
  935. XIX.  A Program to Address the Speed/Detail Dilemma:
  936.         One of the most difficult problems facing graphic application
  937.         developers is speed.  If you haven't noticed, you soon will that
  938.         even a simple application such as displaying The World Digitized
  939.         consumes appriciable time.  People expect response in seconds.
  940.         More than 3 to 5 seconds can be a long wait for some applications.
  941.         The simple display program developed above can display at a rate
  942.         approaching 200 vectors/second on a vanilla IBM PC with math chip
  943.         (not sure it's being used).  That implies that the full The World
  944.         Digitized database, some 100,000+ co-ordinates, would take on
  945.         the order of ten minutes to display!  Fortunately the detail
  946.         of the entire database is not needed when the full breadth of the
  947.         database is presented.  The problem, then, becomes one of dynamically
  948.         trading off detail for speed depending on need.
  949.  
  950.    1.   Design a display module for the simple display program outlined
  951.         above which will minimize display time by using only the detail
  952.         necessary for the current zoom factor.  I am aware of no
  953.         practical solution to this most practical problem.  The solution
  954.         which first jumps to mind is using some form of indexing, first
  955.         of all to limit the range of file scanning for high zooms, and
  956.         secondly to skip the detail unnecessary in large area displays.
  957.         The problems implicit in this solution, however, jump to mind almost
  958.         as fast.  Different levels of indexing would be required by
  959.         differing zoom factors.  A simple file organization into which to
  960.         index isn't obvious.  The twin problems of data scope and detail
  961.         remain.  One trick which may be helpful, however, is to paint the
  962.         central portion of any given display first.  While the user is
  963.         studying what probably interests him most, the program can go on
  964.         to finish the details around the edges or informationally ambiguous
  965.         areas.  (If any of you have a good solution, drop me a line.  I
  966.         may not be able to reply, but I certainly stand ready to learn.)
  967.  
  968.